home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / Xteq X-Setup / xqdcXSP-Setup-EN.exe / {app} / plugins / XQ Mozilla 1.xpl < prev    next >
Text File  |  2002-09-24  |  4KB  |  99 lines

  1. "FILE"="Xteq Systems X-Setup Plugin 6.0"
  2. "TYPE"="6"
  3. "COUNT"="4"
  4. "UIPATH"="Internet\Mozilla"
  5. "NAME"="Startup Options"
  6. "VERSION"="1.0"
  7. "LANGUAGE"="VBScript"
  8. "TEXT 1"="Start Navigator"
  9. "TEXT 2"="Start Mozilla Mail and News"
  10. "TEXT 3"="Start Composer"
  11. "TEXT 4"="Start Address Book"
  12. "DESCRIPTION 1"="When you run the Mozilla executable, normally just the web browser (Navigator) runs. Here, you can allow some of the other programs to run."
  13. "DESCRIPTION 2"="NOTE: This will affect all users of Mozilla on this computer."
  14. "DESCRIPTION 3"="Mozilla is free, open source web browser available from http://www.mozilla.org/ ."
  15. "AUTHOR"="Xteq Systems (Neil R. Turner)"
  16. "CONTACTURL"="http://www.xteq.com"
  17. "COPYRIGHT"="Copyright ⌐ Xteq Systems - All Rights Reserved"
  18. "COMMENT 1"="Rules of programming #46346: Never write plugins with a hangover."
  19.  
  20. ' Neil's attempt at creating a Mozilla plug-in for X-Setup. As you can see, it's a little
  21. ' complicated due to the way Mozilla stores its settings (ie in a completely non-standard
  22. ' format... so much for a standards compliance, eh?), so that's why the code is slightly
  23. ' more sloppy then usual. But it works. I think.
  24. ' Feel free to copy code elements for use in other Mozilla/Netscape plugins.
  25. sP="HKCU\Software\mozilla.org\Mozilla\"
  26. sV1="CurrentVersion"
  27. sV2="\Main\Install Directory"
  28.  
  29. Sub Plugin_Initialize
  30.  ' To find out where the Mozilla keys are stored, we have to go get the version number.
  31.  MozVer=RegReadValue(sP&sV1)
  32.  if IsEmpty(MozVer)=true then
  33.   Call Disable()
  34.  else
  35.  ' This tells us where Mozilla is installed, so that we can open the preferences files.
  36.   InsPath=RegReadValue(sP&MozVer&sV2)
  37.  end if
  38.  
  39.  ' Open all.js, which seems to be the main preference file.
  40.  Call TxtOpen(InsPath&"defaults\pref\all.js")
  41.  
  42.  ' Because we repeat a rather longwinded peace of code to get each setting, we use a SUB,
  43.  ' and provide it with the name of the value and what we would expect it to say if it was
  44.  ' on - for some reason Mozilla likes to put loads of spaces in, thus requiring more code.
  45.  ' It makes it easier to read, but from an X-Setup point of view, it's annoying. Grrrrrrr.
  46.  Call Build_UI("pref(""general.startup.browser"",","             true);",1)
  47.  Call Build_UI("pref(""general.startup.mail"",","                true);",2)
  48.  Call Build_UI("pref(""general.startup.compose"",","             true);",3)
  49.  Call Build_UI("pref(""general.startup.addressbook"",","         true);",4)
  50. End Sub
  51.  
  52. Sub Build_UI(Pref,Setting,Num)
  53.  i=TxtFindLine(Pref,false)
  54.  if i>0 then
  55.   s=TxtGetLine(i)
  56.   i=InStr(s,",") ' We're only interested in the stuff after the comma, so we get rid of the left hand side.
  57.   s=Right(s,len(s)-i)
  58.   if s=Setting then ' If what we've retrieved is the same as what we were expecting, then we set the UI elephant to true.
  59.    Call SetUIElement(Num,true)
  60.   end if
  61.  else
  62.   ' The prefs files may only be written on first launch or be corrupted, so if the item
  63.   ' can't be found, we let the user know.
  64.   Call MsgWarning("X-Setup encountered an error while trying to retrieve the settings. This may be because you have not run Mozilla yet, or the preferences are corrupted. Please run Mozilla, or reinstall it.")
  65.   Call Disable()
  66.  end if
  67. End Sub
  68.  
  69. Sub Plugin_Apply(ElementIndex,ElementSubIndex)
  70.  ' Yup, we need this again... Though since the plugin would already be disabled if it
  71.  ' didn't exist, we can skip a bit.
  72.  MozVer=RegReadValue(sP&sV1)
  73.  InsPath=RegReadValue(sP&MozVer&sV2)
  74.  
  75.  Call DoStuff("pref(""general.startup.browser"",","             true);","             false);",1)
  76.  Call DoStuff("pref(""general.startup.mail"",","                true);","                false);",2)
  77.  Call DoStuff("pref(""general.startup.compose"",","             true);","             false);",3)
  78.  Call DoStuff("pref(""general.startup.addressbook"",","         true);","         false);",4)
  79.  
  80.  Call TxtSave()
  81. End Sub
  82.  
  83. Sub DoStuff(Pref,Enabled,Disabled,Num)
  84.  ' Amazingly, the Apply SUB is smaller than the Initilise SUB. Is this a first in X-Setup?
  85.  s=GetUIElement(Num)
  86.  if s=true then
  87.   i=TxtFindLine(Pref,false)
  88.   Call TxtSetLine(i,Pref&Enabled)
  89.  else
  90.   i=TxtFindLine(Pref,false)
  91.   Call TxtSetLine(i,Pref&Disabled)
  92.  end if
  93. End Sub
  94.  
  95. Sub Plugin_Terminate
  96.  Call TxtClose()
  97. End Sub
  98.